﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Bitis_KeToanThue_Pro_DungChung.Common;

namespace Bitis_KeToanThue_Pro_QuanTri.AccessDatabase
{
   public class PhanNhomNguoiDung
   {
       AccessData ac = new AccessData(1);
       public int xoanhom(int userid, int manhom)
       {
           SqlParameter[] arrPara = new SqlParameter[2];
           arrPara[0] = new SqlParameter("@UserID", SqlDbType.Int);
           arrPara[0].Value = userid;
           arrPara[1] = new SqlParameter("@MaNhomUser", SqlDbType.Int);
           arrPara[1].Value = manhom;
           DataTable dt = ac.ftblDocDuLieuSP("thuan_qtphannhommenu_resetnhomnguoidunganduser", arrPara);
           return int.Parse(dt.Rows[0]["ErrCode"].ToString());
       }
       public DataTable loadgirdnguoidungbymanhom(int manhom)
       {
           SqlParameter[] arrPara = new SqlParameter[1];
           arrPara[0] = new SqlParameter("@MaNhomUser", SqlDbType.Int);
           arrPara[0].Value = manhom;

           return ac.ftblDocDuLieuSP("thuan_qtphannhommenu_loadluoinguoidungbymanhom", arrPara);

       }
       public DataTable loadgirdnhomnguoidungbyuserid(int userid)
       {
           SqlParameter[] arrPara = new SqlParameter[1];
           arrPara[0] = new SqlParameter("@UserID", SqlDbType.Int);
           arrPara[0].Value = userid;

           return ac.ftblDocDuLieuSP("thuan_qtphannhommenu_loadluoinhomnguoidungbyuserid", arrPara);
         
       }
       public int them(int userid,int manhom)
       {
           SqlParameter[] arrPara = new SqlParameter[2];
           arrPara[0] = new SqlParameter("@UserID", SqlDbType.Int);
           arrPara[0].Value = userid;
           arrPara[1] = new SqlParameter("@MaNhomUser", SqlDbType.Int);
           arrPara[1].Value = manhom;
           DataTable dt = ac.ftblDocDuLieuSP("thuan_qtphannhommenu_capnhomnguoidung", arrPara);
           return int.Parse(dt.Rows[0]["ErrCode"].ToString());
       }
       public int xoaonerow(int userid, int manhom)
       {
           SqlParameter[] arrPara = new SqlParameter[2];
           arrPara[0] = new SqlParameter("@UserID", SqlDbType.Int);
           arrPara[0].Value = userid;
           arrPara[1] = new SqlParameter("@MaNhomUser", SqlDbType.Int);
           arrPara[1].Value = manhom;
           DataTable dt = ac.ftblDocDuLieuSP("thuan_qtphannhommenu_resetonerownhomnguoidung", arrPara);
           return int.Parse(dt.Rows[0]["ErrCode"].ToString());
       }
       public int xoa(int userid)
       {
           SqlParameter[] arrPara = new SqlParameter[1];
           arrPara[0] = new SqlParameter("@UserID", SqlDbType.Int);
           arrPara[0].Value = userid;

           DataTable dt = ac.ftblDocDuLieuSP("thuan_qtphannhommenu_resetnhomnguoidung", arrPara);
           return int.Parse(dt.Rows[0]["ErrCode"].ToString());
       }
       public DataTable loadgirdnhomnguoidung()
       {

           return ac.ftblDocDuLieuSP("thuan_qtphannhommenu_loadluoinhomnguoidung", null);
       }
       public DataTable loadgirdnguoidung()
       {

           return ac.ftblDocDuLieuSP("thuan_qtphannhommenu_loadluoinguoidung", null);
       }
    }
}
